{extend name="base_mobile"/}
{block name="body"}
<header class="hui-header">
    <div id="hui-back"></div>
    <h1>编辑资料</h1>
    <div id="hui-header-menu" onclick="hui.showSlideMenu();"></div>
</header>
<div class="hui-wrap">
    <form action="{:request()->url()}" class="hui-form" method="post">
        <div class="hui-form-items">
            <div class="hui-form-items-title">用户名</div>
            <input type="text" value="{$data.username|default=''}" autocomplete="off" class="hui-input hui-input-clear" disabled>
        </div>
        <div class="hui-form-items">
            <div class="hui-form-items-title">用户昵称</div>
            <input type="text" name="realname" value="{$data.realname|default=''}" autocomplete="off" lay-verify="required" class="hui-input">
        </div>
        <div class="hui-form-items">
            <div class="hui-form-items-title">手机号码</div>
            <input type="text" name="mobile" value="{$data.mobile|default=''}" autocomplete="off" lay-verify="phone|number" class="hui-input">
        </div>
        <div class="hui-form-items">
            <div class="hui-form-items-title">E-mail</div>
            <input type="text" name="email" value="{$data.email|default=''}" autocomplete="off" lay-verify="phone|number" class="hui-input">
        </div>
        <div class="hui-form-items">
            <div class="hui-form-items-title">微信绑定</div>
            {if $data.openid==''}
            <a href="javascript:hui.open('{:url('user/weixin/login', ['type' => 'bangding'])}');" class="hui-button hui-button-small hui-danger hui-fl" style="margin:0px 10px;">立即绑定</a>
            {else}
            <?php $wxuser = model('weixinUser')->where(['openid'=>$data['openid']])->find(); ?>
            <a href="javascript:hui.open('{:url('user/weixin/login', ['type' => 'bangding'])}');" class="hui-button hui-button-small hui-danger hui-fl" style="margin:0px 10px;">{$wxuser.nickname}</a>
            {/if}
        </div>
        <div style="padding:15px 8px;">
            <button class="hui-button hui-button-large hui-primary" lay-filter="*" lay-submit="">保存</button>
        </div>
    </form>
</div>
<script src="__LIBS__/layui/layui.all.js"></script>
<script src="__JS__/jquery.min.js"></script>
<script src="__JS__/layui.base.js"></script>
<script type="text/javascript">
        var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;//手机号正则 
        var count = 60; //间隔函数，1秒执行
        var InterValObj1; //timer变量，控制时间
        var curCount1;//当前剩余秒数
        /*第一*/
        function sendMessage1() {
                curCount1 = count;		 		 
                var phone = $.trim($('#mobile').val());
                if (!phoneReg.test(phone)) {
                        alert(" 请输入有效的手机号码"); 
                        return false;
                }
                $.ajax({
                    type: "POST",      //data 传送数据类型。post 传递
                    dataType: 'json',  // 返回数据的数据类型json
                    url: "/user/index/captcha_sms",  // yii 控制器/方法
                    cache: false,      
                    data: {mobile: phone},  //传送的数据
                    error:function(){
                       alert("数据传输错误");
                    },success: function (data) {
                        if(window.console){
                            console.log(data);
                        }else{
                            console.log(data);
                        }
                    }
                });      

                //设置button效果，开始计时
                $("#btnSendCode1").attr("disabled", "true");
                $("#btnSendCode1").val( + curCount1 + "秒再获取");
                InterValObj1 = window.setInterval(SetRemainTime1, 1000); //启动计时器，1秒执行一次
                //向后台发送处理数据

        }
        function SetRemainTime1() {
                if (curCount1 == 0) {                
                        window.clearInterval(InterValObj1);//停止计时器
                        $("#btnSendCode1").removeAttr("disabled");//启用按钮
                        $("#btnSendCode1").val("重新发送");
                }
                else {
                        curCount1--;
                        $("#btnSendCode1").val( + curCount1 + "秒再获取");
                }
        } 

        /*提交*/
        function binding(){
                alert(1)
        }
</script>
{/block}
